import CommonPage from '@/components/page/CommonPage';
import React, { useEffect, useState } from 'react';
import type { Moment } from 'moment';
const daoName = 'Nzjl';
const importName = 'Nzjl';
const columns: API.Column[] = [
  {
    title: '部门',
    width: 110,
    sorter: true,
    key: 'DPNM',
    dataIndex: 'DPNM',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '员工工号',
    width: 110,
    sorter: true,
    dataIndex: 'EMNO',
    key: 'EMNO',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '员工姓名',
    width: 110,
    sorter: true,
    dataIndex: 'EMNM',
    key: 'EMNM',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '业绩绩效调整金额',
    width: 110,
    sorter: true,
    key: 'YJJXTZJE',
    dataIndex: 'YJJXTZJE',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '业务绩效调整金额',
    width: 110,
    sorter: true,
    key: 'YWJXTZJE',
    dataIndex: 'YWJXTZJE',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '调整原因',
    width: 150,
    sorter: true,
    key: 'TZYY',
    dataIndex: 'TZYY',
    dispaly: true,
    filter: true,
    export: true,
  },
];
const controls: API.Control[] = [
  { name: 'DPNM', type: 'text', label: '部门', grid: 12 / 24 },
  { name: 'EMNO', type: 'text', label: '员工工号', grid: 12 / 24 },
  { name: 'EMNM', type: 'text', label: '员工姓名', grid: 12 / 24 },
  {
    name: 'YJJXTZJE',
    rules: [{ required: true }],
    type: 'number',
    label: '业绩绩效调整金额',
    grid: 12 / 24,
    dataType: 'number',
  },
  {
    name: 'YWJXTZJE',
    rules: [{ required: true }],
    type: 'number',
    label: '业务绩效调整金额',
    grid: 12 / 24,
    dataType: 'number',
  },
  {
    name: 'TZYY',
    type: 'text',
    label: '调整原因',
    grid: 12 / 24,
  },
];
const controlsImport: API.Control[] = [
  { name: 'EMNO', type: 'text', label: '员工工号', grid: 12 / 24 },
  { name: 'EMNM', type: 'text', label: '员工姓名', grid: 12 / 24 },
  {
    name: 'YJJXTZJE',
    rules: [{ required: true }],
    type: 'number',
    label: '业绩绩效调整金额',
    grid: 12 / 24,
    dataType: 'number',
  },
  {
    name: 'YWJXTZJE',
    rules: [{ required: true }],
    type: 'number',
    label: '业务绩效调整金额',
    grid: 12 / 24,
    dataType: 'number',
  },
  {
    name: 'TZYY',
    type: 'text',
    label: '调整原因',
    grid: 12 / 24,
  },
];
const Nzjl: React.FC = () => {
  const [paras, setParas] = useState<Record<string, any>>({});
  const [year1, setYear1] = useState<string>(() => {
    const year = new Date();
    const dqyear = year.getFullYear();
    return '' + dqyear;
  });
  useEffect(() => {
    setParas({
      FFND: year1,
    });
  }, [year1]);
  if (paras.FFND === undefined) {
    return <></>;
  }
  return (
    <CommonPage
      daoName={daoName}
      columns={columns}
      controls={controls}
      title="年终奖励调整导入"
      importName={importName}
      importControls={controlsImport}
      importMode="DeleteAfterInsert"
      importParamNames={['FFND']}
      importParamVals={{ FFND: '' + paras.FFND }}
      importTemplateName="年终奖励调整导入模板"
      keyColName="ID"
      shortcutFilters={{
        controls: [
          {
            name: 'FFND',
            dataType: 'number',
            type: 'year',
            label: '选择年份',
            rules: [{ required: true, message: '年份不能为空' }],
            width: 120,
            initValue: paras.FFND,
            onChange: async (m: Moment) => {
              const d = new Date(m.format('YYYY-MM-DD'));
              // eslint-disable-next-line @typescript-eslint/no-shadow
              const year = '' + d.getFullYear();
              setYear1(year);
            },
          },
        ],
      }}
    />
  );
};
export default Nzjl;
